<extend name="Include:Layout"/>
<block name="title">历史订单</block>
<block name="style">
<style>

</style>
</block>

<block name="main">
	<div class="weui_tab">
		<div class="weui_navbar">
			<div class="toolbar">
		        <div class="toolbar-inner">
		            <a href="javascript:history.go(-1);" class="picker-button close-popup">关闭</a>
		            <h1 class="title" id="banji_title">历史订单</h1>
		        </div>
		    </div>
		</div>
		
		<div class="weui_tab_bd container" id="lists" data-page="1">
				
			  <foreach name="list" item="vo">
			  	 <php>
			  	 $type = array(
			  	 	'dashang' => '打赏',
					'baoming' => '课程报名',
					'midbm' =>'课程自定义报名',
					'freepay' => '自定义支付',
					'tiyan' => '体验课',
					'qitatiyan' => '其他体验课',
					'kjbm' => '考级报名',
					'summer2018' => '2018暑期班报名'
			  	 );
				  if($vo['status'] == 1) $status = '<span style="color:green">已支付</span>';
				  if($vo['status'] == 2) $status = '<span style="color:red">未支付</span>';
				  if($vo['status'] == 3) $status = '<span style="color:blue">已过期</span>';
				  </php>
			    <a href="{:U('weixin/pay/index',array(id=>$vo['id']))}">
			        <div class="weui_cells_title">缴费状态：{$status}</div>
				    <div class="weui_cells">
		                <table style="width:100%;" cellpadding="0" cellspacing="0" >
		                	<tr>
		                		<th>编号</th>
		                		<td>{$vo.ddbh}</td>
		                	</tr>
		                	<tr>
		                		<th>类型</th>
		                		<td>{$type[$vo['type']]}</td>
		                	</tr>
		                	<tr>
		                		<th>费用</th>
		                		<td>{$vo.total}</td>
		                	</tr>
		                </table>
				    </div>	
			    </a>
		  </foreach>
		</div>
	</div>
	<div class="weui-infinite-scroll" id='infinite'>
	  <div class="infinite-preloader"></div>
	  正在加载...
	</div>
</block>

<block name="script">
<script>
var loading = false;  //状态标记
$(document.body).infinite().on("infinite", function() {
  if(loading) return;
  loading = true;
  setTimeout(function() {
	var page=$("#lists").attr("data-page");
	$.post('/home/order/get_more',{page:page},function(data){
		var html='';
		var status;
		if(data.info == 'ok'){
			var pdata = data.data;
			for (var i in pdata){
				if(pdata[i].status == '1'){
					status = '<span style="color:green">已支付</span>';
				}
				if(pdata[i].status == '2'){
					status ='<span style="color:red">未支付</span>';
				}
				if(pdata[i].status == '3'){
					status ='<span style="color:blue">已过期</span>';
				}
				html +='<a href="/home/order/detail/id/'+pdata[i].id+'.html">';
				html +='    <div class="weui_cells_title">缴费状态：'+status+'</div>';
				html +='	<div class="weui_cells">';
				html +='        <table style="width:100%;" cellpadding="0" cellspacing="0" >';
				html +='        	<tr>';
			    html +='             	<th>编号</th>';
			    html +='             	<td>'+pdata[i].ddbh+'</td>';
			   	html +='            </tr>';
			    html +='            <tr>';
			    html +='           		<th>姓名</th>';
			    html +='               	<td>'+pdata[i].stuname+'</td>';
			    html +='            </tr>';
			    html +='            <tr>';
			    html +='           		<th>费用</th>';
			    html +='               	<td>'+pdata[i].total+'</td>';
			    html +='            </tr>';
			    html +='        </table>';
			    html +='	</div>';
			    html +='</a>';
			}
			var p = parseInt(page)+1;
			$("#lists").append(html).attr("data-page",p);
			loading = false;
			if(data.next == 'no'){
				$(document.body).destroyInfinite();
				$("#infinite").hide();
			}
		}else{
			$(document.body).destroyInfinite();
			$("#infinite").hide();
		}
		
	})
  
  }, 1500);   //模拟延迟
});
</script>
</block>

